package svc

import (
	"go-zero-project-02/common/init_gorm"
	"go-zero-project-02/rpc_study/user_api_rpc/rpc/internal/config"
	"gorm.io/gorm"
)

type ServiceContext struct {
	Config  config.Config
	MysqlDb *gorm.DB
}

func NewServiceContext(c config.Config) *ServiceContext {
	mySql := init_gorm.InitGorm(c.Mysql.DataSource)
	//mysqlDb.AutoMigrate(&models.UserModel{}) //自动建表
	return &ServiceContext{
		Config:  c,
		MysqlDb: mySql,
	}
}
